package com.unicom.office.node;

import com.sun.org.apache.xpath.internal.operations.Bool;
import com.unicom.office.func.FuncCommon;
import com.unicom.office.type.CellTypeItem;
import com.unicom.office.type.ParagraphTypeItem;
import com.unicom.office.type.TypeItem;
import com.unicom.office.func.FuncBase;
import com.unicom.office.unit.CellUnit;
import com.unicom.office.unit.OfficeUnit;

public class CellNode extends OfficeNode {
    public CellNode(Object source) {
        super(source);
    }

    public void setText(String text, Boolean isNumeric){
        ParagraphNode paragraphNode = new ParagraphNode(null);
        TextRangeNode textRangeNode = new TextRangeNode(null);
        textRangeNode.setText(text, isNumeric);
        paragraphNode.addChild(textRangeNode);
        this.getChildren().clear();
        this.addChild(paragraphNode);
    }

    public ParagraphNode getFirstParagraphNode(){
        return (ParagraphNode)getChildren().get(0);
    }

    public OfficeUnit createUnit() {
        return new CellUnit();
    }

    public boolean testChildType(FuncCommon child) {
        return child.getType() == ParagraphTypeItem.INSTANCE;
    }

    public TypeItem getType() {
        return CellTypeItem.INSTANCE;
    }
}
